﻿//验证码
function change() {
    var imgNode = document.getElementById("vimg");
    imgNode.src = "../ajax/Verification.ashx?t=" + (new Date()).valueOf();  // 这里加个时间的参数是为了防止浏览器缓存的问题
}
//轮播图片
//$(function () {
//    $("#KinSlideshow").KinSlideshow({
//        moveStyle: "left",
//        titleBar: { titleBar_height: 45, titleBar_bgColor: "url(../img/XXX.jpg)", titleBar_alpha: 1 },
//        titleFont: { TitleFont_size: 12, TitleFont_color: "#333", TitleFont_weight: "blod" },
//        btn: { btn_bgColor: "#FFFFFF", btn_bgHoverColor: "#f30", btn_fontColor: "#000000", btn_fontHoverColor: "#FFFFFF", btn_borderColor: "#fff", btn_borderHoverColor: "#fff", btn_borderWidth: 0 }
//    });
//})


// 设置为主页 
function SetHome(obj, vrl) {
    try {
        obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl);
    }
    catch (e) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }
            catch (e) {
                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', vrl);
        } else {
            alert("您的浏览器不支持，请按照下面步骤操作：1.打开浏览器设置。2.点击设置网页。3.输入：" + vrl + "点击确定。");
        }
    }
}
// 加入收藏 兼容360和IE6 
function shoucang(sTitle, sURL) {
    try {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e) {
        try {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e) {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}

function sousuo() {
    var str = $("#input1").val();
    if (str.length > 0) {
        window.location.href = "sousuo.aspx?str=" + str;
    } else {
        alert("请输入搜索内容!");
    }
}

function csubstr(str, len) {
    if (str.length > len) {
        return str.substring(0, len) + "...";
    } else {
        return str;
    }
}

//图片 鼠标滑过效果
function setover(obj) {
    obj.style['opacity'] = 0;
    obj.style['filter'] = 'alpha(opacity=0)';
}
function setout(obj) {
    obj.style['opacity'] = 1;
    obj.style['filter'] = 'alpha(opacity=100)';
}

//时间日期
$(document).ready(function () {
    setInterval(showTime, 1000);
    function timer(obj, txt) {
        obj.text(txt);
    }
    function showTime() {
        var today = new Date();
        var weekday = new Array(7);
        weekday[1] = "星期一"
        weekday[2] = "星期二"
        weekday[3] = "星期三"
        weekday[4] = "星期四"
        weekday[5] = "星期五"
        weekday[6] = "星期六"
        weekday[0] = "星期日"
        var y = today.getFullYear() + "年";
        var month = today.getMonth() + 1 + "月";
        var td = today.getDate() + "日";
        var d = weekday[today.getDay()];
        var h = today.getHours();
        var m = today.getMinutes();
        var s = today.getSeconds();
        h = checkTime(h);
        m = checkTime(m);
        s = checkTime(s);
        timer($("#Y"), y);
        timer($("#MH"), month);
        timer($("#TD"), td);
        timer($("#D"), d);
        timer($("#H"), h + ":");
        timer($("#M"), m + ":");
        timer($("#S"), s);
    }
    function checkTime(i) {
        if (i < 10) {
            i = "0" + i;
        }
        return i;
    }
})

//选项卡
function setTab(m, n) {
    var menu = document.getElementById("tab" + m).getElementsByTagName("li");
    var showdiv = document.getElementById("tablist" + m).getElementsByTagName("div");
    for (i = 0; i < menu.length; i++) {
        menu[i].className = i == n ? "now" : "";
        showdiv[i].style.display = i == n ? "block" : "none";
    }
}
//禁止复制
//document.oncontextmenu = new Function("event.returnValue=false;");
//document.onselectstart = new Function("event.returnValue=false;");


//判断登陆终端
//uaredirect('mobile/Default.aspx');
//function uaredirect(url) {
//    if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad|htc)/i))) {
//        document.location.href = url;
//    }
//}


/*JS Query Ready*/
$(document).ready(function () {
    loadchonghui();

    $(window).resize(function () {
        loadchonghui()
    });
});

//第一屏效果
var speed1 = 500; //第一屏效果 划入速度

function readybanner1() {
    //定义第一屏图像区域
    var h1 = window.innerHeight; //当前屏幕高度
    $(".index-1st-box1").css("height", h1);

    $(".banner-box1").css("height", h1);
    $(".banner-box2").css("height", h1 / 2);
    $(".banner-box3").css("height", h1 / 2);


}

function banner1() {
    //第一屏图像区域动画1
    var box1_w = $(".banner-box1").width();
    var box1_h = $(".banner-box1").height();
    $(".banner-box1 img").css("width", box1_w).css("height", box1_h).css("margin-left", -box1_w * 2);

    $(".banner-box1 img").animate({ marginLeft: "0px" }, speed1);
}

function banner2() {
    //第一屏图像区域动画2
    var box2_w = $(".banner-box2").width();
    var box2_h = $(".banner-box2").height();
    $(".banner-box2 img").css("width", box2_w).css("height", box2_h).css("margin-top", -box2_h);

    $(".banner-box2 img").delay(speed1).animate({ marginTop: "0px" }, speed1);
}
function banner3() {
    //第一屏图像区域动画3
    var box3_w = $(".banner-box3").width();
    var box3_h = $(".banner-box3").height();
    $(".banner-box3 img").css("width", box3_w).css("height", box3_h).css("margin-left", box3_w);

    $(".banner-box3 img").delay(speed1 * 2).animate({ marginLeft: "0px" }, speed1);
}

function bannertext1() {
    var ban1h = $(".banner-box1").height();
    $(".banner-box1-text").delay(speed1 * 3).animate({ marginTop: -(ban1h / 2) - 100 + "px" }, speed1 * 2);

}
function bannertext2() {
    var ban2h = $(".banner-box2").height();
    $(".banner-box2-text").animate({ marginTop: -(ban2h / 2) - 50 + "px" }, speed1 * 2);
}
function bannertext3() {
    var ban3h = $(".banner-box3").height();
    $(".banner-box3-text").animate({ marginTop: -(ban3h / 2) - 50 + "px" }, speed1 * 2);
}
//第二屏效果
function readybanner2() {
    //定义第二屏图像区域
    var h1 = window.innerHeight; //当前屏幕高度
    $(".index-2st").css("height", h1);

    //$(".banner-box1").css("height", h1);
    //$(".banner-box2").css("height", h1 / 2);
    //$(".banner-box3").css("height", h1 / 2);
}
function readybanner2_box() {
    //第二屏中心区域文字效果
    var h1 = window.innerHeight; //当前屏幕高度
    var ind2bh = h1 * 0.7; //第二屏中心区域文字高度

    $(".index-2st-box").css("height", ind2bh);
    $(".index-2st-box").css("margin-top", (h1 - ind2bh) / 2).css("line-height", ind2bh / 5 + "px").css("padding-top", h1 * 0.05);

    //$(".banner-box1").css("height", h1);
    //$(".banner-box2").css("height", h1 / 2);
    //$(".banner-box3").css("height", h1 / 2);
}
//第三屏效果
//function readybanner3() {
//    //定义第三屏图像区域
//    var h1 = window.innerHeight; //当前屏幕高度
//    $(".index-3st").css("height", h1);

//    //$(".banner-box1").css("height", h1);
//    //$(".banner-box2").css("height", h1 / 2);
//    //$(".banner-box3").css("height", h1 / 2);
//}
//背景效果
function readybannerbg() {
    //定义背景图像区域
    var h1 = window.innerHeight; //当前屏幕高度
    $(".index-bg").css("height", h1);
    $(".index-bg-ny").css("height", h1);
    $(".index-bg-ny img").css("height", h1);
}
//载入及重绘
function loadchonghui() {
    readybanner1();

    banner1();
    banner2();
    banner3();


    bannertext1();
    bannertext2();
    bannertext3();

    ////////////////
    readybanner2();
    readybanner2_box();
    ////////////////
    //readybanner3();
    ////////////////
    readybannerbg();

    //search1();
    //share1();
    //characteristic 特效
    characteristic();

    //延迟加载图片
    $("img").lazyload({ effect: "fadeIn" });

    //功能实现-鼠标经过效果
    gnsxmove1();
    setInterval("gnsxmove1()", 100);
    //解决方案-鼠标经过效果
    jjfamove1();
    setInterval("jjfamove1()", 100);
}
/*查询Model*/
function search1() {
    $(".search").hover(function () {
        //移入    
        $(".search").css("height", "72px").css("z-index", "100");
        setTimeout(function () {
            $(".search").animate({ width: "100%" });
        }, 200);
    }, function () {
        //移出
        $(".search").width("72px").height("72px").css("z-index", "1");
    });
}
/*分享Model*/
function share1() {
    $(".share").hover(function () {
        //移入    
        $(".share").css("height", "72px").css("z-index", "100");
        setTimeout(function () {
            $(".share").animate({ width: "100%" });
        }, 200);
    }, function () {
        //移出
        $(".share").width("72px").height("72px").css("z-index", "1");
    });
}

/*characteristic 特效*/
function characteristic() {
    $(".index-3st-box-click-a1").css("background", "#c0edc2");

    $(".index-3st-box-click-a1").hover(function () {
        $(".index-3st-box-a1").stop(true, true).animate({ left: "0px" });
        $(".index-3st-box-a2").stop(true, true).animate({ left: "100%" });
        $(".index-3st-box-click-a1").css("background", "#c0edc2");
        $(".index-3st-box-click-a2").css("background", "none");
    });
    $(".index-3st-box-click-a2").hover(function () {
        $(".index-3st-box-a1").stop(true, true).animate({ left: "-100%" });
        $(".index-3st-box-a2").stop(true, true).animate({ left: "0px" });
        $(".index-3st-box-click-a2").css("background", "#c0edc2");
        $(".index-3st-box-click-a1").css("background", "none");
    });
}



function jjfamove1() {
    var jjfaimg_h = $(".ny-content-body-jjfa-box-k img").height();//解决方案图片高度

    $(".ny-content-body-jjfa-box-k").css("height", jjfaimg_h);//设置单个窗格高度
    $(".ny-content-body-jjfa-box-m").css("height", jjfaimg_h).css("margin-top", -jjfaimg_h).css("line-height", jjfaimg_h - 20 + "px");//设置单个窗格遮罩层高度
}
function gnsxmove1() {
    var gnsximg_h = $(".ny-content-body-gnsx-box-k img").height();//功能实现图片高度

    $(".ny-content-body-gnsx-box-k").css("height", gnsximg_h);//设置单个窗格高度
    $(".ny-content-body-gnsx-box-m").css("height", gnsximg_h).css("margin-top", -gnsximg_h).css("line-height", gnsximg_h - 20 + "px");//设置单个窗格遮罩层高度
}